package org.openmrs.web.controller.user;

import java.util.ArrayList;
import java.util.List;

import javax.servlet.ServletException;
import javax.servlet.http.HttpServletRequest;

import org.openmrs.ObligationContext;
import org.openmrs.api.UserService;
import org.openmrs.api.context.Context;
import org.springframework.web.bind.ServletRequestDataBinder;
import org.springframework.web.servlet.mvc.SimpleFormController;

public class ObligationContextListController extends SimpleFormController {
	
	protected void initBinder(HttpServletRequest request, ServletRequestDataBinder binder) throws Exception {
		super.initBinder(request, binder);
	}
	
	protected Object formBackingObject(HttpServletRequest request) throws ServletException {
		List<ObligationContext> contextList = new ArrayList<ObligationContext>();
		
		if (Context.isAuthenticated()) {
			UserService us = Context.getUserService();
			contextList = us.getAllObligationContexts();
		}
		
		return contextList;
	}
}
